<?php
/*
	会员列表
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	if($_RQ['type']){
		$params['type']=intval($_RQ['type']);
		$return['params']['type']=$_RQ['type'];
	}
	if(!empty($_RQ['name'])){
		$params['name like']='%'.trim($_RQ['name']).'%';
		$return['params']['name']=trim($_RQ['name']);
	}
	if(!empty($_RQ['mobile'])){
		$params['mobile']=trim($_RQ['mobile']);
		$return['params']['mobile']=trim($_RQ['mobile']);
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array();
	$list=pdo_getslice('jy_move_car_member',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			if($item['type']==2){
				$number=pdo_getcolumn('jy_move_car_cards',array('mid'=>$item['mid']),'number');
				$item['card_number']=$this->card_number($number);
				$item['ewm']=custom_url('jy_move_car/move//code='.$item['code'],true);
			}
			if($item['plate']){
					$item['plate']=json_decode($item['plate'],true);
					$item['plate']=$item['plate']['p'].$item['plate']['c'].$item['plate']['number'];
				}else{
					$item['plate']='未设置';
				}
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'车主管理'),
		),
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'list'=>array(
			array('name'=>'avatar','title'=>'头像','type'=>'image'),
			array('name'=>'name','title'=>'姓名','type'=>'string'),
			array('name'=>'type','title'=>'类型','type'=>'radio','options'=>'types'),
			array('name'=>'mobile','title'=>'手机','type'=>'string'),
			array('name'=>'brand','title'=>'汽车品牌','type'=>'string'),
			array('name'=>'plate','title'=>'车牌号','type'=>'string'),
			array('name'=>'card_number','title'=>'挪车卡号','type'=>'string'),
			array('name'=>'ewm','title'=>'二维码','type'=>'ewm'),
		),'action'=>array(
			array('type'=>'post','op'=>'start','title'=>'解除黑名单','show'=>array('status'=>1)),
			array('type'=>'post','op'=>'off','title'=>'加入黑名单','show'=>array('status'=>0)),
			array('type'=>'modal','op'=>'send','title'=>'发送消息'),
			array('type'=>'href','op'=>'detail','title'=>'查看详情'),
		)),
		'search'=>array(
			array('name'=>'type','width'=>15,'title'=>'类型','type'=>'radio','options'=>'types'),
			array('name'=>'name','width'=>15,'title'=>'昵称','type'=>'string'),
			array('name'=>'mobile','width'=>15,'title'=>'手机号','type'=>'string'),
		)
	);
	$return['htmls']=$htmls;
	$return['types']=array(
		'0'=>'全部',
		'1'=>'粉丝',
		'2'=>'车主',
	);
	exi($return);
}
//取消禁止
if($_RQ['op']=='start'){
	
	$id=intval($_RQ['id']);
	if($id){
		$this->update('member',array('status'=>0),array('id'=>$id));	
	}
	exi('取消禁止成功！');
}
  
if($_RQ['op']=='off'){
	
	$id=intval($_RQ['id']);
	if($id){
		$this->update('member',array('status'=>1),array('id'=>$id));
	}
	exi('禁止成功！');
}
//会员详情
if($_RQ['op']=='detail'){
	exi('功能开发中！','error');
}
//发送消息
if($_RQ['op']=='send'){
	exi('功能开发中！','error');
}